//
//  UILabel+JEHLabel.m
//  SinaNews
//
//  Created by 蒋恩浩 on 15/12/18.
//  Copyright © 2015年 JEH. All rights reserved.
//

#import "UILabel+JEHLabel.h"

@implementation UILabel (JEHLabel)

- (void)nightMode {
    
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    if ([[user objectForKey:@"NightMode"] isEqualToString:@"Night"]) {
        
        self.textColor = [UIColor whiteColor];
    } else {
        self.textColor = [UIColor blackColor];
    }
}

- (void)searchLabel:(UILabel *)label withAttributedText:(NSString *)attributedText {
    
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    if ([[user objectForKey:@"NightMode"] isEqualToString:@"Night"]) {
        
        self.textColor = [UIColor whiteColor];
    } else {
        self.textColor = [UIColor blackColor];
    }
    NSRange range = [label.text rangeOfString:attributedText];
    NSMutableAttributedString *heightLightString = [[NSMutableAttributedString alloc] initWithString:label.text];
    [heightLightString setAttributes:@{NSForegroundColorAttributeName : [UIColor redColor], NSFontAttributeName : [UIFont systemFontOfSize:17]} range:range];
    label.attributedText = heightLightString;
}

@end
